package cn.xiongxf.context;

import cn.xiongxf.domain.Login;
import com.alibaba.fastjson.JSON;
import org.springframework.security.core.Authentication;
import org.springframework.security.core.context.SecurityContextHolder;

public class LoginContextHolder {
    public static Login getLogin(){
        try {
            Authentication authentication = SecurityContextHolder.getContext().getAuthentication();
            return JSON.parseObject(authentication.getPrincipal().toString(), Login.class);
        } catch (Exception e) {
            e.printStackTrace();
            return null;
        }

    }
}
